/*
 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 SPDX-License-Identifier: Apache-2.0
*/

@use '../internal/styles/' as styles;
@use 'segment' as seg;
@use 'sass:list' as list;
@use '../internal/styles/tokens' as awsui;

@function repeatValue($value, $times) {
  $result: ();

  @for $i from 1 through $times {
    $result: list.append($result, $value);
  }

  @return $result;
}

.root {
  @include styles.styles-reset;
}

.segment-part {
  display: inline-grid;
  border-inline: solid awsui.$border-width-field awsui.$color-border-input-default;
  border-block: solid awsui.$border-width-field awsui.$color-border-input-default;
  border-start-start-radius: awsui.$border-radius-button;
  border-start-end-radius: awsui.$border-radius-button;
  border-end-start-radius: awsui.$border-radius-button;
  border-end-end-radius: awsui.$border-radius-button;
  background-color: awsui.$color-background-segment-wrapper;
  align-items: center;
  min-block-size: calc(awsui.$line-height-body-m + awsui.$space-static-xxs);
  padding-block: calc(seg.$segment-gap / 2 - awsui.$border-width-field);
  padding-inline: calc(seg.$segment-gap - awsui.$border-width-field);
  gap: calc(#{seg.$segment-gap} * 2 + #{seg.$segment-divider-width});

  &:not(.refresh) {
    padding-inline: calc(awsui.$space-static-xxxs + awsui.$border-width-field);
    padding-block: 0;
    gap: calc(#{seg.$segment-gap} * 2 - #{seg.$segment-divider-width});
  }

  @include styles.media-breakpoint-down(styles.$breakpoint-x-small) {
    display: none;
  }
}

.select {
  display: none;

  @include styles.media-breakpoint-down(styles.$breakpoint-x-small) {
    display: block;
  }
}

@for $i from 2 through 6 {
  .segment-count-#{$i} {
    // The repeat syntax is not used since it is broken when using with SASS together
    grid-template-columns: repeat(#{$i}, auto);
  }
}

.disabled-reason-tooltip {
  /* used in test-utils or tests */
}
